package versionx

import "gitee.com/zhongguo168a/gocodes/datax"

type IObject interface {
	RefGet(field string) (val interface{})
	RefSet(field string, val interface{})

	// 字段的路径
	RefFieldPath() string
	//
	RefFieldChanged() bool

	RefHas(field string) (val bool)
	// basic
	RefInt(field string) (val int)
	RefFloat64(field string) (val float64)
	RefString(field string) (val string)
	RefBool(field string) (val bool)
	RefArray(field string) datax.A
	RefMap(field string) IObject
	// object
	RefClass(field string) IObject
	RefClassCreator(field string, creator func(object IObject) IObject)

	RefLastVersion() int
	RefVersions() map[string]int
	RefVersionComplete()
	KeyVersionReset()

	// 设置为nil
	RefSetNil()
	RefNew() IObject
	RefNewIfNil() IObject
	RefIsNil() bool
	RefKeys() []string
	RefData() datax.M
	RefLength() int
	RefReset(val map[string]interface{})
	RefUpdate(data map[string]interface{})
	RefRemove(field string)

	//FromMap(m datax.M)
	//fromMap(m datax.M)
	ToMapVersion() (r datax.M)
	toMapVersion(target datax.M)
	ToMap() (r datax.M)
	toMap(target datax.M)
	ToMapByField(fieldMap datax.M) (r datax.M)
}

// 根
type IRoot interface {
	IObject
	// 获取编号
	// field="_id"
	RefId() string
	RefIdSet(val string)
	RefClone() (r *Root)
	RefIsRemove() bool

	RefDispose()
	RefOnChange(func(path, field string, val interface{}))
	RefReset(val map[string]interface{})
}
